package org.mch.func.str.edit;

import java.awt.BorderLayout;
import java.awt.Font;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;

import org.fife.ui.rtextarea.RTextArea;
import org.mch.biz.ui.FuncEvent;
import org.mch.biz.ui.FuncPanel;
import org.mch.swingm.core.MButton;
import org.mch.swingm.core.MTextField;

/**
 * 描述：字符串编辑；<BR/>
 *
 * @author MCH；Date：2008-06-18；<BR/>
 *
 */
public class ClientPanel extends FuncPanel {
	private static final long serialVersionUID = -7445205265477699919L;

	private JSplitPane splitPane;
	private JPanel panel;
	private JPanel panel_1;
	private RTextArea text_str;
	private MButton btn_execute;
	private JScrollPane scrollPane;
	private JRadioButton radio_01;
	private MTextField text_01;
	private JRadioButton radio_02;
	private MTextField text_02;

	public ClientPanel() {
		initGUI();
		ButtonGroup btnGroup = new ButtonGroup();
		btnGroup.add(getRadio_01());
		btnGroup.add(getRadio_02());
	}

	private void initGUI() {
		setLayout(new BorderLayout(0, 0));
		add(getSplitPane(), BorderLayout.CENTER);
	}

	protected FuncEvent createEvent() {
		return new ClientEvent(this);
	}

	public JSplitPane getSplitPane() {
		if (splitPane == null) {
			splitPane = new JSplitPane();
			splitPane.setDividerSize(3);
			splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
			splitPane.setLeftComponent(getPanel_1());
			splitPane.setRightComponent(getPanel_1_1());
			splitPane.setDividerLocation(200);
		}
		return splitPane;
	}

	public JPanel getPanel_1() {
		if (panel == null) {
			panel = new JPanel();
			panel.setLayout(null);
			panel.add(getBtn_execute());
			panel.add(getRadio_01());
			panel.add(getText_01());
			panel.add(getRadio_02());
			panel.add(getText_02());
		}
		return panel;
	}

	public JPanel getPanel_1_1() {
		if (panel_1 == null) {
			panel_1 = new JPanel();
			panel_1.setLayout(new BorderLayout(0, 0));
			panel_1.add(getScrollPane_1(), BorderLayout.CENTER);
		}
		return panel_1;
	}

	public RTextArea getText_str() {
		if (text_str == null) {
			text_str = new RTextArea();
			text_str.setFont(new Font("宋体", Font.PLAIN, 13));//
		}
		return text_str;
	}

	public MButton getBtn_execute() {
		if (btn_execute == null) {
			btn_execute = new MButton("执行");
			btn_execute.setBounds(593, 164, 102, 25);
			btn_execute.addActionListener(getEvent());
		}
		return btn_execute;
	}

	public JScrollPane getScrollPane_1() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setViewportView(getText_str());
		}
		return scrollPane;
	}

	public JRadioButton getRadio_01() {
		if (radio_01 == null) {
			radio_01 = new JRadioButton("每行开头前增加字符串：");
			radio_01.setFont(new Font("宋体", Font.PLAIN, 13));//
			radio_01.setBounds(6, 6, 181, 26);
		}
		return radio_01;
	}

	public JTextField getText_01() {
		if (text_01 == null) {
			text_01 = new MTextField();
			text_01.setBounds(193, 6, 138, 26);
			text_01.setColumns(10);
		}
		return text_01;
	}

	public JRadioButton getRadio_02() {
		if (radio_02 == null) {
			radio_02 = new JRadioButton("第行结尾后增加字符串：");
			radio_02.setFont(new Font("宋体", Font.PLAIN, 13));//
			radio_02.setBounds(6, 38, 181, 26);
		}
		return radio_02;
	}

	public JTextField getText_02() {
		if (text_02 == null) {
			text_02 = new MTextField();
			text_02.setColumns(10);
			text_02.setBounds(193, 38, 138, 26);
		}
		return text_02;
	}
}